#include "StdAfx.h"
#include ".\cfilename.h"

CFileName::CFileName(void) : CString()
{
}

CFileName::CFileName(const TCHAR* str) : CString(str)
{
}

CFileName::~CFileName(void)
{
}


CString CFileName::GetFileName()
{
    int pos = ReverseFind('\\')+1;
    if (pos == 0) pos = ReverseFind('/')+1;

    CString res = Mid(pos);
    pos = res.ReverseFind('.');
    if (pos != -1) res.Delete(pos,res.GetLength()-pos);

    return res;
}


void CFileName::ChangeFileName(const TCHAR* str)
{
    int pos = ReverseFind('\\')+1;
    if (pos == 0) pos = ReverseFind('/')+1;

    Delete(pos,GetLength()-pos);
    Append(str);
}


void CFileName::ChangeExtention(const TCHAR* str)
{
    int pos = ReverseFind('.')+1;
    if (pos == 0) pos = GetLength();

    Delete(pos,GetLength()-pos);
    Append(str);
}